﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using ADA.Entity;
using System.Data;
using System.Data.SqlClient;

namespace ADA.Data
{
    public class DALWarehouse
    {
        //private string conStr = ConfigurationManager.AppSettings["connectionString"];
        private string conStr = Common.CONNECTION_STRING;

        public void deleteWarehouseByUserID(long userID)
        {
            string sql = @"DELETE FROM  [WareHouse]
                                WHERE   [WareHouse].[UserID] = @userID";
                                
            SqlConnection conn = new SqlConnection(conStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.Add("@userID", SqlDbType.BigInt).Value = userID;

            cmd.ExecuteNonQuery();
            conn.Close();
        }

        public void deleteWarehouseByRiceID(int riceID)
        {
            string sql = @"DELETE FROM  [Warehouse]
                                WHERE   [Warehouse].[RiceID] = @riceID";

            SqlConnection conn = new SqlConnection(conStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.Add("@RiceID", SqlDbType.Int).Value = riceID;

            cmd.ExecuteNonQuery();
            conn.Close();
        }
    }
}
